﻿using Microsoft.Xna.Framework;
using Sparklings.RayTracing;
using System.Collections.Generic;

namespace Sparklings.LevelElements
{
    public class Spot
    {
        public Spot(Vector2 position, Vector2 direction, RayColor c)
        {
            Position = position;
            Direction = direction;
            color = c;
            rays = new List<ColoredRay>();
            rays.Add(new ColoredRay());
            rays[0].Origin = Position;
            rays[0].Direction = Direction;
            rays[0].Color = Color;
        }
        public virtual IEnumerable<ColoredRay> Rays
        {
            get
            {
                if (On)
                {
                    return rays;
                }
                else
                {
                    return new List<ColoredRay>();
                }
            }
        }
        public Vector2 Direction;
        public Vector2 Position;
        public RayColor Color
        {
            get { return color; }
            set
            {
                color = value;
                foreach (var ray in rays)
                {
                    ray.Color = value;
                }
            }
        }
        public float HitDistance { get { return rays[0].HitDistance; } }
        private List<ColoredRay> rays;
        private RayColor color;
        public bool On;
    }
}
